<include file="public@header" />
</head>
<body>
    <div class="wrap">
        <ul class="nav nav-tabs">
            <li><a href="{:url('storages/index')}">列表</a></li>
            <li class="active"><a >{:lang('ADD')}</a></li>
        </ul>
        <form method="post" class="form-horizontal js-ajax-form margin-top-20" enctype="multipart/form-data" action="{:url('storages/add')}">
            <div class="row">

                <div class="form-group">
                    <label for="input-name" class="col-sm-2 control-label">名称</label>
                    <div class="col-md-6 col-sm-10">
                        <input type="text" class="form-control" name="store_name" value="{$data.store_name|default=''}">
                    </div>
                </div>

                <div class="form-group">
                    <label for="input-name" class="col-sm-2 control-label">支持平台</label>
                    <div class="col-md-6 col-sm-10">
                        <input type="text" class="form-control" name="plattype" value="{$data.plattype|default=''}">
                    </div>
                </div>

                <div class="form-group">
                    <label for="input-name" class="col-sm-2 control-label">价格</label>
                    <div class="col-md-6 col-sm-10">
                        <input type="text" class="form-control"  name="price" value="{$data['price']|default=0.00}">
                    </div>
                </div>


                <div class="form-group">
                    <label for="input-name" class="col-sm-2 control-label">省</label>
                    <div class="col-md-6 col-sm-10">
                        <input type="text" class="form-control" name="province" value="{$data.province|default=''}">
                    </div>
                </div>
                <div class="form-group">
                    <label for="input-name" class="col-sm-2 control-label">市</label>
                    <div class="col-md-6 col-sm-10">
                        <input type="text" class="form-control" name="city" value="{$data.city|default=''}">
                    </div>
                </div>
                <div class="form-group">
                    <label for="input-name" class="col-sm-2 control-label">区县</label>
                    <div class="col-md-6 col-sm-10">
                        <input type="text" class="form-control" name="area" value="{$data.area|default=''}">
                    </div>
                </div>
                <div class="form-group">
                    <label for="input-name" class="col-sm-2 control-label">详细地址</label>
                    <div class="col-md-6 col-sm-10">
                        <input type="text" class="form-control" name="send_address" value="{$data.send_address|default=''}">
                    </div>
                </div>

                <div class="form-group">
                    <label for="input-name" class="col-sm-2 control-label">发货人</label>
                    <div class="col-md-6 col-sm-10">
                        <input type="text" class="form-control" name="sender" value="{$data.sender|default=''}">
                    </div>
                </div>
                <div class="form-group">
                    <label for="input-name" class="col-sm-2 control-label">电话</label>
                    <div class="col-md-6 col-sm-10">
                        <input type="text" class="form-control" name="tel" value="{$data.tel|default=''}">
                    </div>
                </div>

                <div class="form-group">
                    <label for="input-name" class="col-sm-2 control-label">备注</label>
                    <div class="col-md-6 col-sm-10">
                        <input type="text" class="form-control" name="mark" value="{$data.mark|default=''}">
                    </div>
                </div>

                <div class="form-group">
                    <label for="" class="col-sm-2 control-label">快递公司</label>
                    <div class="col-md-6 col-sm-10">
                        <select name="express_code" id="" class="form-control">
                            <option value="">请选择</option>
                            <volist name="express" id="vo">
                                <option value="{$vo.Code}">{$vo.Name}</option>
                            </volist>
                        </select>
                        <p class="help-block">若该处没有要选择的快递公司，请联系平台客服或者开发人员进行对接</p>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('确认')}</button>
                        <a class="btn btn-default" href="javascript:history.back(-1);">{:lang('BACK')}</a>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <script src="__STATIC__/js/admin.js"></script>
    <script>
        function setManage(){
            var e = document.getElementById('mid');
            $.ajax({
                url: "storage_list",    // 提交到controller的url路径
                type: "post",    // 提交方式
                data: {mid: e.value},  // data为String类型，必须为 Key/Value 格式。
                dataType: "json",    // 服务器端返回的数据类型
                success: function (data) {
                    if (data.code == 1) {
                        console.log(data)
                        $('#sid').empty();
                        if (data.data.length > 0){
                            for (var i=0; i<data.data.length; i++){
                                $('#sid').append('<option value="'+data.data[i]['id']+'">'+data.data[i]['name']+'</option>')
                            }
                        }else {
                            console.log('nothing');
                        }
                    } else {
                        alert(data.msg);
                    }
                },
            });
        }

        setPrice();
        function setPrice(){
            var e = document.getElementById('sid');
            console.log(e.label)
        }
    </script>
</body>
</html>